<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:oso="http://osoftware.com/facelets"
	template="/WEB-INF/templates/mainEditLayout.xhtml">
	
	<ui:define name="title">
			#{resourceBundle['attentionTime.title']}
	</ui:define>
	
	<ui:define name="editFields">
		<p:wizard widgetVar="attentionTimeWizard" flowListener="#{attentionTimeController.onFlowProcess}" backLabel="#{resourceBundle['wizard.back']}" nextLabel="#{resourceBundle['wizard.next']}">
			
			<p:tab id="attentionTimeData" title="1. Turno">
				<h:panelGrid columns="3">
					<oso:calendar id="timeAndDate" label="#{resourceBundle['attentionTime.timeAndDate']}"
						value="#{attentionTimeModel.timeAndDate}" required="true" includeTime="true"/>	
					<oso:inputText id="attentionOrder" label="#{resourceBundle['attentionTime.attentionOrder']}"
						value="#{attentionTimeModel.attentionOrder}" required="true"/>
				</h:panelGrid>
			</p:tab>
			<p:tab id="patientData" title="2. Paciente">
				<h:panelGrid columns="3">
					<oso:selectOneMenu id="patient" 
						label="#{resourceBundle['attentionTime.patient']}"
						value="#{attentionTimeModel.patient}" 
						converter="patientConverter"
						items="#{attentionTimeModel.selectablePatients}" 
						itemLabel="fullName"
						required="true">
					</oso:selectOneMenu>
					<p:commandButton action="newPatient" value="Nuevo Paciente" process="@this"/>
					<h:outputText value="" />
				</h:panelGrid>
			</p:tab>
			<p:tab id="specialistData" title="3. Especialista">
				<p:panelGrid columns="3" >
					<oso:selectOneMenu id="speciality"
						label="#{resourceBundle['schedule.speciality']}"
						value="#{attentionTimeModel.speciality}"
						converter="specialityConverter"
						items="#{attentionTimeModel.selectableSpecialities}"
						itemLabel="name">
						<p:ajax event="change"
							listener="#{attentionTimeController.onSpecialityChange}"
							update="specialist" />
					</oso:selectOneMenu>

					<oso:selectOneMenu id="specialist"
						label="#{resourceBundle['schedule.specialist']}"
						value="#{attentionTimeModel.specialist}"
						converter="specialistConverter"
						items="#{attentionTimeModel.selectableSpecialists}"
						itemLabel="fullName">
						<p:ajax event="change"
							update="specialistFee" />
					</oso:selectOneMenu>
					<oso:selectOneMenu id="specialistFee" 
						label="#{resourceBundle['attentionTime.specialistFee']}"
						value="#{attentionTimeModel.specialistFee}" 
						converter="specialistFeeConverter"
						items="#{attentionTimeModel.specialist.fees}" 
						itemLabel="description"
						required="true" >
						<p:ajax event="change"
							listener="#{attentionTimeController.onSpecialistFeeChange}"
							update="fee" />
					</oso:selectOneMenu>
					<oso:inputText id="fee" label="#{resourceBundle['attentionTime.fee']}"
						value="#{attentionTimeModel.fee}" required="true"/>
				</p:panelGrid>
			</p:tab>
			<p:tab id="finishData" title="3. Finalizar" rendered="false">
				<p:commandButton action="newPayment" value="Guardar y Pagar" process="@this"/>
			</p:tab>
			<p:tab id="paymentData" title="3. Pago" rendered="false">
				<h:panelGrid columns="1">
					<oso:selectOneMenu id="paymentType" 
						label="#{resourceBundle['attentionTime.paymentType']}"
						value="#{attentionTimeModel.paymentType}" 
						converter="paymentTypeConverter"
						items="#{attentionTimeModel.selectablePaymentTypes}" 
						itemLabel="name"
						required="true"/>
				</h:panelGrid>
			</p:tab>
			<p:tab id="cashPaymentData" title="3.1 Efectivo" rendered="false">
				<h:panelGrid columns="1">

				</h:panelGrid>
			</p:tab>
			<p:tab id="prepaidPaymentData" title="3.2 Obra Social" rendered="false">
				<oso:selectOneMenu id="patientPrepaid" 
					label="#{resourceBundle['attentionTime.patientPrepaid']}"
					value="#{attentionTimeModel.patientPrepaid}" 
					converter="patientPrepaidConverter"
					items="#{attentionTimeModel.specialist.prepaids}" 
					itemLabel="description"
					required="true" >
				</oso:selectOneMenu>				
			</p:tab>
		</p:wizard>
		<h:outputText value="" />
		<h:outputText value="" />
	</ui:define>
	
</ui:composition>